<?php
header('Content-Type: text/html; charset=UTF-8');
require_once("Connections/cnn.php");
require_once("functions.php");
$semail = addslashes($_REQUEST['email']);

if ($_GET['email'] !== "")
{
	$sql_query = @mysql_query("SELECT * FROM Members WHERE Email='{$semail}'");
	$member = @mysql_fetch_array($sql_query);
	
	if (@mysql_num_rows($sql_query) <= 0)
	{
		//redirectMsg is definced function in functions.php file.
		RedirectMsg('Email does not exist','login.php');
	}
	
	$spass = addslashes(md5($_REQUEST['pass']));     
		                        
	if ($spass == $member['Password'])
	{
		session_start();
		$_SESSION['memberID'] = $member['ID'];
		$_SESSION['memberName'] = $member['Firstname'];
		
		RedirectMsg('Login successfully','index.php');
		@mysql_close($conn);
	}
	else
	{
		RedirectMsg('Password is wrong','login.php');
	}
}
else
{
//redirect is definced function in functions.php file.	
Redirect('index.php');						
}
?>